<html lang="en" xmlns:th="http://www.thymeleaf.org">

<form id="form_dict_input" class="form-horizontal">
    <input type="hidden" name="keyId" th:value="${dict?.id}" />
    <input type="hidden" name="dictType" th:value="${dictType?.name()}" />

    <div class="form-group">
        <label class="col-md-3 control-label">字典类</label>
        <div class="col-md-7">
            <input disabled type="text" th:value="${dictType?.value()}" class="form-control">
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 control-label">内容<i class="fa fa-asterisk txt-color-red"></i></label>
        <div class="col-md-7">
            <input type="text" name="name" id="name" th:value="${dict?.name}" class="form-control" placeholder="请输入内容">
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 control-label">关键字</label>
        <div class="col-md-7">
            <input type="text" name="value" id="value" th:value="${dict?.value}" class="form-control" placeholder="请输入关键字">
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 control-label">描述信息</label>
        <div class="col-md-7">
            <input type="text" name="description" id="description" th:value="${dict?.description}" class="form-control" placeholder="请输入描述信息">
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 control-label">排序号</label>
        <div class="col-md-7">
            <input type="number" name="sortNo" id="sortNo" th:value="${dict?.sortNo}" class="form-control" placeholder="请输入排序号">
        </div>
    </div>

</form>

<script th:inline="javascript">
    $(function(){
        fn_dict_input_validate();
    });

    function fn_dict_input_validate(){
        __init_validate("form_dict_input", {
            name : {
                required : true
            },
            sortNo : {
                digits : true,
                min : 0
            }
        });
    }

    function fn_dict_save(callback){
        if(!$("#form_dict_input").valid()){
            return false;
        }
        __form_save("form_dict_input", "/main/dict/save", function(data){
            callback(data);
        })
    }

</script>

</html>